/**
 * 物业相关类型定义
 * 
 * @author Wu.Liang
 * @since 2025-06-29
 */

import type { ApiResponse, PageResult } from './index'

// ==================== 物业公司相关类型 ====================

// 物业公司查询参数
export interface PropertyCompanyQueryParams {
  current: number
  size: number
  companyName?: string
  companyCode?: string
  contactPerson?: string
  contactPhone?: string
  status?: number
  auditStatus?: number
  qualificationLevel?: string
}

// 物业公司表单数据
export interface PropertyCompanyFormData {
  companyName: string
  companyCode: string
  businessLicense?: string
  legalRepresentative?: string
  contactPerson: string
  contactPhone: string
  contactEmail?: string
  address?: string
  establishedDate?: string
  registeredCapital?: number
  serviceScope?: string
  qualificationLevel?: string
  paymentQrCode?: FileInfo[] // 支持多文件
  paymentAccount?: string
  paymentBank?: string
  paymentLink?: string
  wechatPayMerchantId?: string
  alipayMerchantId?: string
  companyLogo?: FileInfo[] // 支持多文件
  introduction?: string
  businessHours?: string
  serviceHotline?: string
}

// 物业公司审核数据
export interface PropertyCompanyAuditData {
  auditStatus: number
  auditRemark?: string
}

// 物业公司实体 - 更新文件字段支持多文件
export interface PropertyCompany {
  id: number
  companyName: string
  companyCode: string
  creditCode?: string
  businessLicense?: string
  legalRepresentative?: string
  contactPerson: string
  contactPhone: string
  contactEmail?: string
  email?: string
  address?: string
  description?: string
  establishedDate?: string
  registeredCapital?: number
  serviceScope?: string
  qualificationLevel?: string
  paymentQrCode?: FileInfo[] // 支持多文件
  paymentAccount?: string
  paymentBank?: string
  paymentLink?: string
  wechatPayMerchantId?: string
  alipayMerchantId?: string
  companyLogo?: FileInfo[] // 支持多文件
  introduction?: string
  businessHours?: string
  serviceHotline?: string
  status: number
  statusName?: string
  auditStatus: number
  auditStatusName?: string
  auditRemark?: string
  auditBy?: number
  auditTime?: string
  createBy?: number
  createTime?: string
  updateBy?: number
  updateTime?: string
}

// 物业公司统计信息
export interface PropertyCompanyStats {
  totalCount: number
  activeCount: number
  inactiveCount: number
  pendingAuditCount: number
  approvedCount: number
  rejectedCount: number
  qualificationLevelStats: Array<{ level: string; count: number }>
  monthlyGrowth: Array<{ month: string; count: number }>
}

// ==================== 物业信息相关类型 ====================

// 文件信息类型
export interface FileInfo {
  id: string
  fileName: string
  fileUrl: string
  fileSize: number
  uploadType: string
  uploadSource: string
  status: string
  createTime: string
  fileType?: string
  fileExtension?: string
  fileMd5?: string
  originalFileName?: string
  filePath?: string
  thumbnailUrl?: string
  description?: string
  tags?: string
  isPublic?: boolean
  downloadCount?: number
  viewCount?: number
  sortOrder?: number
  remark?: string
}

// 物业信息实体
export interface PropertyInfo {
  propertyCompanyId: number
  companyCode: string
  companyName: string
  
  // 基本信息
  creditCode?: string
  businessLicense?: string
  legalRepresentative?: string
  establishedDate?: string
  registeredCapital?: number
  qualificationLevel?: string
  
  // 联系信息
  address: string
  contactPerson: string
  contactPhone: string
  contactEmail: string
  email?: string
  businessHours?: string
  serviceHotline?: string
  
  // 服务信息
  serviceScope: string
  
  // 支付信息
  paymentAccount: string
  paymentBank: string
  paymentLink?: string
  wechatPayMerchantId?: string
  alipayMerchantId?: string
  
  // 图片信息 - 支持多文件
  companyLogo?: string
  paymentQrCode?: string
  
  // 描述信息
  introduction: string
  description?: string
  remark?: string
  
  // 状态信息
  status?: number
  statusName?: string
}

// 物业信息更新数据
export interface PropertyInfoUpdateData {
  // 基本信息
  companyName?: string
  companyCode?: string
  propertyCompanyId?: number
  creditCode?: string
  businessLicense?: string
  legalRepresentative?: string
  establishedDate?: string
  registeredCapital?: number
  qualificationLevel?: string
  
  // 联系信息
  contactPerson?: string
  contactPhone?: string
  contactEmail?: string
  email?: string
  address?: string
  businessHours?: string
  serviceHotline?: string
  
  // 服务信息
  serviceScope?: string
  
  // 支付信息
  paymentAccount?: string
  paymentBank?: string
  paymentLink?: string
  wechatPayMerchantId?: string
  alipayMerchantId?: string
  
  // 图片信息 - JSON字符串格式
  companyLogo?: string
  paymentQrCode?: string
  
  // 描述信息
  introduction?: string
  description?: string
  remark?: string
}

// 物业信息统计数据
export interface PropertyInfoStats {

  totalCommunities: number
  totalHouseholds: number
  averageServiceQuality: number
  monthlyIncome: number
  monthlyExpense: number
  profitRate: number
  serviceStats?: {
    totalEmployees: number
    activeOrders: number
    completedOrders: number
    customerSatisfaction: number
  }
  financialStats?: {
    totalRevenue: number
    totalExpense: number
    netProfit: number
    paymentRate: number
  }
}

// ==================== 物业公司与社区关联相关类型 ====================

// 物业公司与社区关联实体
export interface PropertyCompanyCommunity {
  id: number
  propertyCompanyId: number
  communityId: number
  status: number
  startTime?: string
  endTime?: string
  remark?: string
  createBy?: number
  createTime?: string
  updateBy?: number
  updateTime?: string
}

// 社区分配请求数据
export interface CommunityAssignmentRequest {
  communityIds: number[]
}

// 可分配社区信息
export interface AvailableCommunity {
  id: number
  name: string
  address: string
  description?: string
}

// 物业公司社区关联统计
export interface PropertyCompanyCommunityStats {
  totalCount: number
  activeCount: number
  inactiveCount: number
  terminatedCount: number
}

// ==================== API响应类型 ====================

// 物业公司列表响应
export type PropertyCompanyListResponse = ApiResponse<PageResult<PropertyCompany>>

// 物业公司详情响应
export type PropertyCompanyDetailResponse = ApiResponse<PropertyCompany>

// 物业公司统计响应
export type PropertyCompanyStatsResponse = ApiResponse<PropertyCompanyStats>

// 物业信息响应
export type PropertyInfoResponse = ApiResponse<PropertyInfo>

// 物业信息统计响应
export type PropertyInfoStatsResponse = ApiResponse<PropertyInfoStats>

// 物业公司社区关联列表响应
export type PropertyCompanyCommunityListResponse = ApiResponse<PropertyCompanyCommunity[]>

// 可分配社区列表响应
export type AvailableCommunityListResponse = ApiResponse<AvailableCommunity[]>

// 物业公司社区关联统计响应
export type PropertyCompanyCommunityStatsResponse = ApiResponse<PropertyCompanyCommunityStats>

// ==================== 枚举类型 ====================

// 物业公司状态枚举
export enum PropertyCompanyStatus {
  DISABLED = 0,
  ENABLED = 1
}

// 物业公司审核状态枚举
export enum PropertyCompanyAuditStatus {
  PENDING = 0,
  APPROVED = 1,
  REJECTED = 2
}

// 物业公司资质等级枚举
export enum PropertyCompanyQualificationLevel {
  LEVEL_ONE = '一级',
  LEVEL_TWO = '二级',
  LEVEL_THREE = '三级'
}

// 物业信息状态枚举
export enum PropertyInfoStatus {
  DISABLED = 0,
  ENABLED = 1
}

// 物业公司与社区关联状态枚举
export enum PropertyCompanyCommunityStatus {
  INACTIVE = 0,
  ACTIVE = 1,
  TERMINATED = 2
}

// ==================== 常量定义 ====================

// 物业公司状态选项
export const PROPERTY_COMPANY_STATUS_OPTIONS = [
  { label: '禁用', value: PropertyCompanyStatus.DISABLED },
  { label: '启用', value: PropertyCompanyStatus.ENABLED }
]

// 物业公司审核状态选项
export const PROPERTY_COMPANY_AUDIT_STATUS_OPTIONS = [
  { label: '待审核', value: PropertyCompanyAuditStatus.PENDING },
  { label: '审核通过', value: PropertyCompanyAuditStatus.APPROVED },
  { label: '审核拒绝', value: PropertyCompanyAuditStatus.REJECTED }
]

// 物业公司资质等级选项
export const PROPERTY_COMPANY_QUALIFICATION_LEVEL_OPTIONS = [
  { label: '一级', value: PropertyCompanyQualificationLevel.LEVEL_ONE },
  { label: '二级', value: PropertyCompanyQualificationLevel.LEVEL_TWO },
  { label: '三级', value: PropertyCompanyQualificationLevel.LEVEL_THREE }
]

// 物业信息状态选项
export const PROPERTY_INFO_STATUS_OPTIONS = [
  { label: '停用', value: PropertyInfoStatus.DISABLED },
  { label: '正常', value: PropertyInfoStatus.ENABLED }
]

// 物业公司与社区关联状态选项
export const PROPERTY_COMPANY_COMMUNITY_STATUS_OPTIONS = [
  { label: '停用', value: PropertyCompanyCommunityStatus.INACTIVE },
  { label: '正常', value: PropertyCompanyCommunityStatus.ACTIVE },
  { label: '终止', value: PropertyCompanyCommunityStatus.TERMINATED }
] 